#!/usr/bin/python3
# -*- coding: utf-8 -*-

import pandas as pd
import numpy  as np
import talib as ta

eps = 1e-8

def signal(*args):
    # ChangeStd
    df = args[0]
    n = args[1]
    factor_name = args[2]

    rtn = df['close'].pct_change()
    df[factor_name] = df['close'].pct_change(n) * rtn.rolling(n).std(ddof=0)

    return df
